import { get } from './communication'
import { ROOM_ID_URL } from "./constant";

// TODO: 发送信息给后端处理
type ID = { value: number }

export async function new_room_id(name: string, password: string | null): Promise<number> {
    console.log('get room id: password: ' + password)
    let headers = new Headers();
    headers.append('Content-Type', 'application/json')
    const res = await fetch(ROOM_ID_URL, {
        body: JSON.stringify({ name, password }),
        headers,
        method: 'POST'
    });
    const id: ID = await res.json()
    return id.value
}

// TODO: 发送信息给后端处理
export function drop_room(id: number) {
    // nothing
}